package com.njzxw.fs.commonutil.web;

import com.njzxw.fs.commonutil.util.LoadSpringBean;
import com.sun.javafx.event.EventUtil;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import java.util.logging.Logger;

@Component
public class ApplicationReadyEventListener implements ApplicationListener<ApplicationReadyEvent> {

    public org.slf4j.Logger logger = LoggerFactory.getLogger(this.getClass());

    @Value("${spring.application.name}")
    private String serverId;

    @Value("${server.port}")
    private String port;

    @Autowired
    private LoadSpringBean loadSpringBean;

    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        logger.info("服务启动成功。。。。。。服务id:"+serverId+" 端口号："+port);
        //加载外部对应的spring插件
        loadSpringBean.reload();
    }

}
